package net.butfly.bus.server.invoker;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 可调用的Bean包装类
 * 
 */
public class BeanWrapper {
	/**
	 * Bean实例
	 */
	private Object bean;

	/**
	 * 调用方法
	 */
	private Method method;

	public BeanWrapper(Object bean, Method method) {
		this.bean = bean;
		this.method = method;
	}

	public Object getBean() {
		return bean;
	}

	public Method getMethod() {
		return method;
	}

	public String toString() {
		return bean.getClass().getName() + ":" + method.toString();
	}

	/**
	 * 方法调用
	 * 
	 * @param args
	 * @return
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 */
	public Object invoke(Object[] args) throws IllegalArgumentException, IllegalAccessException,
			InvocationTargetException {
		return method.invoke(bean, args);
	}
}
